<template>
	<view>
		<cu-custom :isBack="true" bgColor="bg-gradual-fff">
			<block slot="content">测评结果</block>
		</cu-custom>
		<u-loading-page :loading="true" loading-text="loading..." v-if="showLoading"></u-loading-page>
		<view v-show="!showLoading">
			<view class="viewbox"></view>
			<view class="group1">
				<view class="p">
					<view class="text1">{{title}}</view>
				</view>
				<view class="content">
					<template v-if="type==='speciality'">
						<view v-for="(item,index) in speciality" :key="index" class="line">
							<text>{{item}}</text>
						</view>
						<view class="line">
							<text>{{starContent.map(el => el.content).join('')}}</text>
						</view>
						<view class="line">
							<text>{{internalExternalCodeContent.map(el => el.content).join('。')}}</text>
						</view>
						<view class="line">
							<text>{{unionCodesContent.map(el => el.content).join('。')}}</text>
						</view>
					</template>
					<template v-if="type==='emotion'">
						<view v-for="(item,index) in emotion" :key="index" class="line">
							<text>{{item}}</text>
						</view>
					</template>
					<template v-if="type==='partner'">
						<view v-for="(item,index) in partner" :key="index" class="line">
							<text>{{item}}</text>
						</view>
					</template>
					<template v-if="type==='sex'">
						<view v-for="(item,index) in sex" :key="index" class="line">
							<text>{{item}}</text>
						</view>
					</template>
					<template v-if="type==='work'">
						<view v-for="(item,index) in work" :key="index" class="line">
							<text>{{item}}</text>
						</view>
					</template>
					<template v-if="type==='improve'">
						<view v-for="(item,index) in improve" :key="index" class="line">
							<text>{{item}}</text>
						</view>
					</template>
				</view>
			</view>
			<!-- <view class="group2">
				<navigator url="/pages/test_center/evaluate"><button class="btn">写评价</button></navigator>
			</view> -->
		</view>	
	</view>
</template>
<script>
	import {
		getPrimaryCodeContent
	} from '@/utils/primaryCode.js'
	import {
		getWealthCodeContent,
		getMakeMoneyContent
	} from '@/utils/wealthCode.js'
	import {
		getStartContent
	} from '@/utils/starCode.js'
	import {
		getInternalExternalCodeContent
	} from '@/utils/internalExternalCode.js'
	import {
		getUnionCodesContent
	} from '@/utils/unionCode.js'
	export default {
		data() {
			return {
				title: '',
				type: '',
				params: {},
				primaryCodeContent: {},
				makeMoneyContent: {
					content: []
				},
				wealthCodeContent: {
					mean: '',
					content: ''
				},
				starContent: [],
				internalExternalCodeContent: [],
				unionCodesContent: [],
			}
		},
		onLoad: function(option) { //option为object类型，会序列化上个页面传递的参数
			const params = JSON.parse(option.data || "{}")
			const selfBirthday = params.selfBirthday
			const sex = params.sex
			this.type = params.type
			this.title = params.title
			if (!selfBirthday || !sex) {
				return
			}
			this.primaryCodeContent = getPrimaryCodeContent(selfBirthday, sex)
			this.wealthCodeContent = getWealthCodeContent(selfBirthday)
			this.makeMoneyContent = getMakeMoneyContent(selfBirthday)
			this.starContent = getStartContent(selfBirthday)
			this.internalExternalCodeContent = getInternalExternalCodeContent(selfBirthday)
			this.unionCodesContent = getUnionCodesContent(selfBirthday)
		},
		computed: {
			speciality() {
				return this.primaryCodeContent?.speciality || []
			},
			emotion() {
				return this.primaryCodeContent?.emotion || []
			},
			partner() {
				return this.primaryCodeContent?.partner || []
			},
			sex() {
				return this.primaryCodeContent?.sex || []
			},
			work() {
				return this.primaryCodeContent?.work || []
			},
			improve() {
				return this.primaryCodeContent?.improve || []
			},
		},
		methods: {}
	}
</script>

<style  lang="scss" scoped>
	.group1{
		margin: auto;
		margin-top: 60rpx;
		width: 700rpx;
		height: auto;
		border-radius: 20rpx;
		box-shadow: inset 0 0 20rpx 20rpx rgba(85, 56, 105, 1);
		padding: 40rpx;
	}
	.p{
		overflow: hidden;
	}
	.text1{
		// position: absolute;
		font-family: PingFang SC;
		font-weight: 500;
		font-size: 30rpx;
		color: #FFFFFF;
		line-height: 120rpx;
	}
	.content{
		width:100%;
		height: auto;
		font-family: PingFang SC;
		font-weight: 500;
		font-size: 26rpx;
		color: #FFFFFF;
		line-height: 48rpx;
	}
	.group2{
		width: 750rpx;
		height: 120rpx;
		background: #FFFFFF;
		border-radius: 10rpx 10rpx 0rpx 0rpx;
		border: 1px solid #F2F2F2;
		position: fixed;
		bottom: 0rpx;
	}
	.btn{
		margin-top: 16rpx;
		width: 330rpx;
		height: 88rpx;
		background: #62469B;
		border-radius: 44rpx;
		

		font-family: PingFang SC;
		font-weight: 500;
		font-size: 30rpx;
		color: #FFFFFF;
		line-height: 90rpx;
	}
</style>
